home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 January / maximum-cd-2002-01.iso / Files / Mechwarrior 4 Mapping / MW4Editor.exe / content / ABLScripts / GenericScripts / Reinforcement.tpl < prev    next >
Encoding:
Text File  |  2001-07-16  |  7.7 KB  |  237 lines

  1.  
  2. //------------------------------------------------------------------
  3. // NOTE: The fsm name below MUST be changed in order for the
  4. // script to be considered a unique entity!
  5.  
  6. UIFIELDS
  7. {
  8. FIELD<         INT,attackRange,"Attack Range",500>;        // At what range do I start shooting?
  9. FIELD<         INT,withdrawRange,"Withdraw Range",750>;        // At what range do I withdraw from combat entirely?
  10. FIELD<          INT,piloting,"Piloting Skill",50>;            // Piloting skill
  11. FIELD<          INT,gunnery,"Gunnery Skill",50>;            // Gunnery skill/chance to hit
  12. FIELD<          FLOAT,minDelay,"Minimum fire Delay",1.0>;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  13. FIELD<          FLOAT,maxDelay,"Maximum fire Delay",2.0>;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  14. FIELD<          INT,eliteLevel,"Elite Level",60>;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  15.                                                     // and other things.  It indicates a general level of combat experience.
  16. FIELD<           INT,isShotRadius,"Is Shot Radius",120>;        // How far away from me will I detect an enemy shot?        
  17. FIELD<INT,    takeOffDistance,"Take Off Distance (ignored if not a plane)",160>;
  18. FIELD<INT,    attackThrottle,"Percent throttle when in combat",80>;
  19.  
  20. FIELD<INT, trigger,"ID of trigger that makes the unit wake up",1>;
  21.  
  22. FIELD<INT, speed,"Movement Speed",600>;        
  23. FIELD<INT, DestX,"X coordinate of destination (-1 = none)",-1>;
  24. FIELD<INT, DestY,"Y coordinate of destination (-1 = none)",-1>;
  25. FIELD<INT, DestZ,"Z coordinate of destination (-1 = none)",-1>;
  26. }
  27.  
  28. fsm Generic_Reinforcement : integer;
  29.  
  30.  
  31. //------------------------------------------------------------------
  32.  
  33. // Generic_Reinforcement:
  34. //   Shuts down, waits until a trigger, powers up, moves to a specific
  35. //   point (if specified) and attacks anything that comes near
  36.  
  37. //------------------------------------------------------------------
  38.  
  39.  
  40.  
  41. //------------------------------------------------------------------
  42. //     Constants
  43. //------------------------------------------------------------------
  44.  
  45.     const
  46.         #include_ <content\ABLScripts\mwconst.abi>
  47.  
  48. //------------------------------------------------------------------
  49. //     Types
  50. //------------------------------------------------------------------
  51.  
  52.     type
  53.         #include_ <content\ABLScripts\mwtype.abi>
  54.     
  55.  
  56. //------------------------------------------------------------------
  57. //     Variables
  58. //------------------------------------------------------------------
  59.  
  60.     var
  61.     static integer            attackRange1;        // At what range do I start shooting (as I'm moving to the point)?
  62.     static integer            attackRange2;        // At what range do I start shooting (as a reinforcement)?
  63.     static integer            withdrawRange;        // At what range do I stop shooting (as a reinforcement)?
  64.  
  65.     static integer            triggerID;            // The index of my global trigger
  66.     static LocPoint            destination;        // The destination to move to when ready
  67.                                                                 
  68.     static integer            piloting;            // Piloting skill
  69.     static integer            gunnery;            // Gunnery skill/chance to hit
  70.     static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  71.     static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  72.     static integer             speed;                // What speed so I move at?
  73.     static integer             elitelevel;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  74.                                                 // and other things.  It indicates a general level of combat experience.
  75.     static integer            attackThrottle;        // My attack throttle
  76.     static integer            findTypes;            // What kind of enemies to look for
  77.  
  78.      static integer            isshotradius;        // How far away from me will I detect an enemy shot?
  79.  
  80.     static integer             attackSound;        // The attack sound I play when I first attack
  81.     static integer             deathSound;            // The sound I play when I die
  82.  
  83.     static integer            mood;                // My default mood.
  84.  
  85.     static integer            takeOffDistance;    // My take-off distance if I'm an airplane (ignored if not an airplane)
  86.  
  87. //------------------------------------------------------------------
  88. //     Init: my initialization function
  89. //------------------------------------------------------------------
  90.  
  91. function Init;
  92.     code
  93.     
  94.         // Variables set by editor
  95.         attackRange1        = <attackRange>;
  96.         withdrawRange    = <withdrawRange>;
  97.         takeOffDistance    = <takeOffDistance>;
  98.          piloting        = <piloting>;
  99.         gunnery            = <gunnery>;
  100.         minDelay        = <minDelay>;
  101.         maxDelay        = <maxDelay>;
  102.         eliteLevel        = <eliteLevel>;
  103.         isShotRadius    = <isShotRadius>;
  104.     attackThrottle    = <attackThrottle>;
  105.         speed            = <speed>;
  106.         triggerID        = <trigger>;
  107.       destination[0]    = <DestX>;
  108.         destination[1]    = <DestY>;
  109.         destination[2]    = <DestZ>;
  110.  
  111.         // script-specific variables
  112.  
  113.         attackRange2    = attackrange1;
  114.  
  115.  
  116.  
  117.  
  118.         // driver settings
  119.         attackSound        = -1; // no sound
  120.         deathSound        = -1; // no sound
  121.         mood            = NEUTRAL_START;
  122.         findTypes        = FT_DEFAULT;
  123.  
  124. endfunction;
  125.  
  126. //------------------------------------------------------------------
  127. //    StartState: my initial state
  128. //------------------------------------------------------------------
  129.  
  130. state StartState;
  131.  
  132.     code
  133.         SetFiringDelay            (ME,minDelay,maxDelay);
  134.         SetIgnoreFriendlyFire    (ME,true);
  135.         SetIsShotRadius            (ME,isshotradius);
  136.         SetEntropyMood            (ME,mood);
  137.         SetCurMood                (ME,mood);
  138.         SetSkillLevel            (ME,piloting,gunnery,elitelevel);
  139.         SetAttackThrottle        (ME,attackThrottle);
  140.                 
  141.         trans ShutdownAndWaitState;
  142.  
  143. endstate;        
  144.  
  145. //------------------------------------------------------------------
  146. //    ShutdownAndWaitState: shut down and wait for the trigger to be set, then go
  147. //------------------------------------------------------------------
  148.  
  149. state ShutdownAndWaitState;
  150.     code
  151.         Shutdown(ME);
  152.  
  153.         if ((GetGlobalTrigger(triggerID)) or (isshot(me))) then
  154.             if (orderTakeOff(takeOffDistance) == true) then
  155.                 Startup(ME);
  156.  
  157.                 if ((destination[0] == -1) and (destination[1] == -1) and (destination[2] == -1)) then
  158.                     trans AttackState;
  159.                 endif;
  160.  
  161.                 trans MoveToPointState;
  162.             endif;
  163.         endif;
  164.  
  165. endstate;
  166.  
  167. //------------------------------------------------------------------
  168. //    MoveToPointState: go to the destination, and attack when we get there
  169. //------------------------------------------------------------------
  170.  
  171. state MoveToPointState;
  172.     code
  173.         if (OrderMoveToLocPoint(destination,speed,true,true)) then
  174.             orderstopattacking;
  175.             SetTarget(ME,NO_UNIT);
  176.             trans WaitAtPointState;
  177.         else
  178.             if (FindEnemy(attackRange1,findTypes)) then
  179.  
  180.                 if (attackSound <> -1) then    
  181.                     PlaySoundOnce(attackSound);
  182.                 endif;
  183.  
  184.                 OrderAttack(false);
  185.             endif;
  186.         endif;
  187. endstate;
  188.  
  189. //------------------------------------------------------------------
  190. //    WaitAtPointState: I got to the point; let's look around
  191. //------------------------------------------------------------------
  192.  
  193. state WaitAtPointState;
  194.     code
  195.         if (FindEnemy(attackRange2,findTypes)) then
  196.             trans AttackState;
  197.         endif;
  198. endstate;
  199.  
  200. //------------------------------------------------------------------
  201. //    AttackState: let's find someone and hurt them
  202. //------------------------------------------------------------------
  203.  
  204. state AttackState;
  205.     code
  206.         if (LeaveAttackState(withdrawRange)) then
  207.             OrderStopAttacking;
  208.             SetTarget(ME,NO_UNIT);
  209.             trans MoveToPointState;
  210.         endif;
  211.  
  212.         if (attackSound <> -1) then    
  213.             PlaySoundOnce(attackSound);
  214.         endif;
  215.  
  216.         OrderAttack(TRUE);
  217.  
  218. endstate;
  219.  
  220. //------------------------------------------------------------------
  221. //    DeadState: OK, I kicked the bucket.
  222. //------------------------------------------------------------------
  223.  
  224. state DeadState;
  225.   code
  226.         if (deathSound <> -1) then    
  227.             PlaySoundOnce(deathSound);
  228.         endif;        
  229.  
  230.         orderDie;
  231.  
  232. endstate;
  233.  
  234.  
  235. endfsm.
  236.  
  237.